/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.fin.controller;

import java.util.List;
import java.util.Map;

import com.dian.common.annotation.SysLog;
import com.dian.modules.fin.vo.ReceiDetailExportVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.dian.common.controller.AbstractController;
import com.dian.modules.fin.entity.ReceiDetailEntity;
import com.dian.modules.fin.service.ReceiDetailService;
import com.dian.common.utils.PageUtils;
import com.dian.common.utils.R;

/**
 * 收款明细单
 *
 * @author 赵淼
 * @email 1752060891@qq.com
 * @date 2019-06-15 16:33:49
 */
@RestController
@Api("收款明细单接口")
@RequestMapping("fin/receiDetail")
public class ReceiDetailController extends AbstractController{
    @Autowired
    private ReceiDetailService receiDetailService;

    /**
     * 收款明细单列表
     */
    @SysLog("收款明细单列表")
    @GetMapping("/list")
    @ApiOperation("收款明细单列表")
    @RequiresPermissions("fin:receiDetail:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = receiDetailService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 收款明细单信息
     */
    @SysLog("收款明细单信息")
    @ApiOperation("收款明细单信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("fin:receiDetail:info")
    public R info(@PathVariable("id") Long id){
        ReceiDetailEntity receiDetail = receiDetailService.getInfo(id);
        return R.ok().put("receiDetail", receiDetail);
    }

    /**
     * 收款明细单保存
     */
    @SysLog("收款明细单保存")
    @ApiOperation("收款明细单保存")
    @PostMapping("/save")
    @RequiresPermissions("fin:ReceiDetail:save")
    public R save(@RequestBody ReceiDetailEntity receiDetail){

		receiDetailService.saveInfo(receiDetail);

        return R.ok();
    }

    /**
     * 收款明细单修改
     */
    @SysLog("收款明细单修改")
    @ApiOperation("收款明细单修改")
    @PostMapping("/update")
    @RequiresPermissions("fin:receiDetail:update")
    public R update(@RequestBody ReceiDetailEntity receiDetail){

		receiDetailService.updateInfo(receiDetail);

        return R.ok();
    }

    /**
     * 收款明细单删除
     */
    @SysLog("收款明细单删除")
    @ApiOperation("收款明细单删除")
    @PostMapping("/delete")
    @RequiresPermissions("fin:receiDetail:delete")
    public R delete(@RequestBody Long[] ids){
		receiDetailService.deleteInfo(ids);

        return R.ok();
    }

    /**
     * 收款明细单审核
     */
    @SysLog("收款明细单审核")
    @ApiOperation("收款明细单审核")
    @GetMapping("/check/{id}")
    @RequiresPermissions("fin:receiDetail:check")
    public R check(@PathVariable("id") Long id){

        receiDetailService.checkInfo(id);
        return R.ok();
    }

    /**
     * 收款明细单作废
     */
    @SysLog("收款明细单作废")
    @ApiOperation("收款明细单作废")
    @GetMapping("/cancel/{id}")
    @RequiresPermissions("fin:receiDetail:cancel")
    public R cancel(@PathVariable("id") Long id){

        receiDetailService.cancelInfo(id);
        return R.ok();
    }



     /**
     * 收款明细单导出
     */

    @SysLog("收款明细单导出")
    @ApiOperation("收款明细单导出")
    @GetMapping("/export")
    @RequiresPermissions("fin:receiDetail:export")
    public void export(@RequestParam Map<String, Object> params) {

        List<ReceiDetailExportVO> list = receiDetailService.exportList(params);


        exportExcel(list,"收款明细表","收款明细表",ReceiDetailExportVO.class,"收款明细表.xls");
    }

}
